Optimize logic of permission evaluation