Merge pull request #398 from gabrielmcoelho/patch-1

Remove out-of-bounds index comparison