Input logic

modified the input logic.