Fixed bug in directory existence check