[PLAT-3014] Fixing bug in master searches which can lead to corrupt security definitions
Optimisation from Elaine