Further enhanced the code and added an interface to be used in the terminal