Added A-Priori algorithm