Rewrite the formula & fixed bugs