main script update

add "working directory" in parameters, replace any static path to $dir