use path.isEmpty() instead of path.size() < 1