Better path detection