added more debugging output and removed end spaces