refactor hash iteration to one line