js reafctoring and more user-friendly behavior for sidebar menu