refactoring tome.js