added logic to check if on primary. Will test on secondary.