preparing changes to sync_and_demodulate function