minor refactoring to head.js