directory checking functionality