better logging and errors