refactored input controller