refactoring and cleaning up log output