logging + refactor