minor fix in database exist query