Simplify code, make permissions work