removed iterating code in favor of built-in cmp