Fix array out of bounds error in parser