refactor of geometry.js, applying pattern