added function to check bounds, add bounds tests