works properly on command line