Added logic to switch streams if master