this algorithm can be expressed more formally using pseudocode