refactored input a bit