moving calculate-margin function external. fixing defect with really long task name