Logic for Input