Yeah its nuts. The big bugs were, an off by one error, an off by one error (in the other direction), and the wrong Boolean value. I mean honestly.