refectory and mark the function finished to 'done'