Removed rounding to get more accurate numbers and put Ajax call in a mehtod.