Added bound checking