refactor bound check