switched constatnt time compare algorithm