Update base.js

Refactorized common code in base router