A bit more error handling