refactored stateful permission