Added bounds checks