added stream synchronization