refact logging