Eception while dealing with an array