Prevent index out of bound errors