optimize permission checking