Solved index out of bound exception while navigating