# Deriving the charge as a function of time in a discharging capacitor

There is obviously something I have not understood well. In Kirchoff's second law, we take the potential difference of batteries and capacitors with the sign that we traverse it. So, let's assume that we decide to traverse the circuit below clockwise.

By the loop law, we have $$-IR+\frac{q(t)}{C}=-\frac{dq}{dt}R+\frac{q(t)}{C}=0,$$ where $q(t)$ is the charge left in the capacitor as a function of time. Solving the above equation, we find $$q(t)=Qe^{\frac{t}{RC}},$$ where $Q$ the charge in the capacitor the moment it started discharging (assumed to be $t=0$). This solution is obviously wrong, as $q(t)$ needs to fall off exponentially, and not increase. What am I doing wrong?