fixed debug logic