Refactor boundaries.js