Modified method to obtain basedir for script path