add function to flatten sectors