allocate function