refactoring to have a separate check