Refactored asserts to separate function