modified calcW to calcualte the l parameter of davids score