extracted assert bounds method
refactored a bit