Update

Added try and catch and throwing IndexOutOfBoundsExceptions