fixed small db query