Added permissions worker function to implement a more DRY approach