Improved the error checking on the equals call