Refactor the construction of folders