fixed wrong db query