Move input handling to separate file