clean up and function check