Added a relatively complex path calculating algorithm