fix datastore and permissions check