refactoring the checkings