improve logging
improve error handling