cleaning the code

and the math