added exceptions for index out of bound