Bug fixed to take care of thearray length going beyond the limit