add the main compare logic