fix end condition in bounds