addedd better logging, error handling