Add logic to detect script path