updated to use phase to correct drift