Beginning of input handling