navigateUp and Down functions improved to allow flexibility in changing looping from the last to first pages and vice-versa.