removed unnecessary clone and added some more debugging outputs