fixed issues with database query wildcards