refactor permission control system