changed input validation to be cleaner and removed unused imports