Converted deletePermission function to use the new query function