cleanup and seperate version for debug and use