moved order_needed function within file