Tweaking for better error handling