Saving the logarithmic factor in the error term estimates of some congruence problems