Fix permission query