Refactor permission filter