Usually, a good try is, when you're off by one (a common error), and you have a > with a skipped over number, try changing the > to >=.
I can't tell if that's the problem here, because your snippet of code is small and your variable names, like z, are meaningless to me.