And what do we have in there, if not delays... They are quite short (8-10ms in total) but it's still possible that that is what's messing with you.
I don't know what you intended to do with that latest version though, why do you have two cases with the same value, just put the code for both in one.