reduce code size of tools.js