fix to handle empty section lists

moving responsibilities around for cleaner code
function refactoring

no functional changes, just cleaner more explicit code