implemented routing logic, replaced explicit function calls with state-based navigation