clean up of function