fixing navigation issues, refactored some extra code.