1) use underscore.js. 2) put categories in object