story calculation rewrite