Implemented allocate_task