Removed unnecessary parameter.
Tried to optimize timer, added terminal state check.