remove debug output
remove some debug output; move code to the right function