refactored the code and added menu.js file