edited DB query