Updated query to use parameterised condition
Migrated additional conditions to parameterised conditions