cleaned up the code and made the phase shift code