improved WebRT code