rewrote nearphase functions on same signature