Fixed formats.js to make it more organized