Added first input handling and input state