pulled out the comparisons into a different method