new method for generating navigation
created algorithm for displaying navigation in the correct order