added diretory checks