refactors logging