refactor attr method