replace string parsing with array iteration