safer and better logging