Prevent array out of bounds exceptions