refactor error statement