better path resolving, previous wasnt working in many cases