In the book of Tom M. Apostol introduction to analytic number theory in the prove of theorem 3.3 the sum of divisor function $d(n)$
$$\sum_{n<x}^{}1 =\sum_{n<x}^{}\sum_{d|n} 1$$
He said that this sum can extend to sum over lattice point in the qd plane
I don't understand how he gets this equality
$$\sum_{n<x}d(n)=\sum_{n<x} \sum_{q<x/d} 1$$
Can someone explains this technique
$$\sum_{n<x}\sum_{d\mid n}1 = \sum_{n<x}\sum_{dq=x}1= \sum_{n<x}\sum_{d<x}\mathbf1_{dq=n}=\sum_{d<x}\sum_{n<x}\mathbf 1_{dq=n}=\sum_{d<x}\sum_{dq<x}1=\sum_{d<x}\sum_{q<x/d}1$$ where $\mathbf 1_\varphi=1$ if $\varphi$ is true, and $0$ otherwise.