Made error handling less confusing