refactor the permission checking into a dict.