filters user input without loosing state