Add logging when user writes invalid input. Clean up code