added path finding, refactoring