Corrected version of PhasingFinal2.py