Refactor margin top calculation.