refactoring check logic.