not working properly. removing orders from array while using length so missing orders