Fixed a bug in finding right paths