replaced use of Dir.exists since it is not available in v1.8