fix for illegal division by zero

I forgot to change {speed} back to {max} when I removed the speed
variable