update and cleaning code