better logging and error handling in setup method