Supermassive black hole (SMBH) binaries within galaxy mergers are the primary target for low-frequency gravitational wave (GW) observatories. Understanding the coalescence process of SMBH binaries in a cosmological context is critical for accurate GW predictions. However, traditional galaxy formation simulations often merge SMBHs instantaneously at kpc or sub-kpc separation scales due to resolution limitations, leading to significant uncertainty in estimating SMBH coalescence time-scales. In this talk, I will introduce the KETJU code, a newly developed numerical tool capable of simultaneously following galaxy (hydro-)dynamics and resolving SMBH dynamics with post-Newtonian corrections down to a few tens of Schwarzschild radii. This numerical tool enables us to improve the estimation of the SMBH merger time-scales, especially in gas-rich galaxy mergers, and study the impact of SMBH dynamics on galaxy properties.