refactoring regions.js