! Make the query more generic so it can be reused

Signed-off-by: Spuds <spuds@spudsdesign.com>