Fix permission checking