patching (not sure that in correct way) ticks calculation for residual program