clean up and reupdate code