Pav algorithm optimization