added better navigation code