OK, well, it was really stupid!!! so sorry to take up anyone's time (and thank you VSarkiss for tryine!!)....it turned out that my loops were poorly constructed, and the condition that i thought was failing was never getting tested at all.
it works fine now
just had to work through it a little