fixed index out of bounds error for input-5