Refractored permissions api