adding the actual ctr script and adding debug output