minor refactoring of the assertion logic