fixing the earnings calculation