Rewrote folds to make it more readable