how to calculate margin