end of process function