Replaced parseInt by Math.round()