prevent browser to show error when using decimals
improve code using for cycle
improve style