Set up function for determining which algorithm to use.