major refactoring
add permit rules