upgraded integrator to handle any integer type