split logic from command line tool