logic and logging recator - togather