implemented EPA algorithm