Updated checkDirectory