fix debug logic