Improved equality checking