add permission checking function.