Updated to allow for more than one dead end. Cleaned up and working