start implementing closest pi0 function