refactoring & debug logs