Minor refactoring to selectCallback function