select-application: refactoring