Fixed a bug where the phase gradient was decreasing