simplify and better logging