Added bounds detection.