implement bound checking