isn't a break required here? you can be possibly looping here and redefining "finalpath"