made setwd more robust