improved security query