Added a bit of input filter logic