Refactor attributes generating algorithm