refactor logging a bit