refactored sections function