improved error handling
merged todo