More error checking for findObject
Move definition of path