[TASK] Make path detection more reliable