Refactor to use Folding Library