Added a bounds check