Code for lab8, navigating a maze