refactor iterating attributes