minor cleanup
string rep
cleanup
simplify loop with conditions