resource.isDirectory would be better here?