optimized if-statement for checking if the directory exists