factor = 5; thisComp.layer("G").position.speed/factor;
max = 500; factor = 5; s = thisComp.layer("G").position.speed/factor; Math.min(max, s);