updated perc($margin) to margin() function