Minor fix: fixed formulas;

TODO:
-Clean code;
-Optimization;
-Testing.