Refactor active nav code