fixed the bug but still contains a lot of debug output