some errorchecking for existence of directories