working version - from commandline