refactored input capture