Fixed array out of bounds error