refactor in bounds check