Converted getPermissions to use the new query function