Updated bounds checking to work