Fixing Array out of bounds error!