Refactor select_attribute method