Added access check for directories