added code for phase coherence