target directory should be created if it does not exist