refactor(select): reduce duplication and reorder functions