Added functions to use in both algorithms.