Almost working command line version