Better error-checking