Thats why math_min is there. With the original version, every midi value represents a range of 0.78 % 
In your version every Midi value represents a range of 0.78 % except 127
Dis you have issues with the original version?