Split loadFolders() into smaller functions