It was an easy enough fix. This line: Needs to be this: Changing the "less than" test to "less than or equal to". If anyone doesn't want to change it themselves, I put it here: http://pastebin.com/9Ta39Dqk