refactoring to improve ability to support folders