move logs creation earlier