adding outofbounds exception handling