added phase tracking for changing frequencies