fixed check for duplicate condition