Fixed invalid permission check