modified to be an interactive command line program
minor refactors and added comments