refactoring for command finding