added console user interface
added test and refactored