Refactored to provide a proper error