tidying and added command line interface