Fixed improper permissions check