clean up and add debug