clean up and comment code