input check refactored