optimised some math-code