re-factored code on compute and compare.