Refactored bound checking