command line find function refactored