Refactoring, fixing JS script for setting menu.