included error handling for arrayOutOfBoundException