Fixes #6 : Proper array bounds checking