Modified to fix case insensitive queries to be database agnostic