process user input refactored, unit tests added