We know that if $ \displaystyle d(n)= \sum\limits_{d \mid n} 1$, then we have
$ \sum\limits_{n \leq x} d(n)= x\log{x} + (2C-1)x + \mathcal{O}(\sqrt{x})$
I have referred Apostol's "Analytic Number theory" and i understood the first half of the proof where the error term is $\mathcal{O}(x)$, but please tell me as to how to improve the error term to $\sqrt{x}$.