Thanks for the help! I wanted to try a more random solution and I ended up using kind of a clumsy aproach. I now change r,g and b each with a random speed, which seems to work alright in smoothly shifting through the colors in a randomish manner, Cleaner solutions always welcome.
if(r+rv >= 240) rv = -1 + Math.random()*-step;
else if(r+rv <= 20) rv = 1 + Math.random()*step;
if(g+gv >= 240) gv = -1 + Math.random()*-step;
if(g+gv <= 20) gv = 1 + Math.random()*step;
if(b+bv >= 240) bv = -1 + Math.random()*-step;
else if(b+bv <= 20) bv = 1 + Math.random()*step;
r += rv;
g += gv;
b += bv;