Refactor input complement and input check.