cleanup and fix tem var bug
up