Refactored the source code further, added command line arguments