Refactored to support asserts