Added permission detection