Fixing debug logic