Refactor and clean up the surrounded regions