adding navbar and slightly refactoring some JS