Handle edge case, and refactor error case