make permission checking code readable
make permission checking code more readable
fix typo