refactoring more javascript
fixing and refactoring the category menu appending