Fix functionality of algorithm to provide correct paths