clean up code before record