added in bounds checking