refactor attr to use map