refactored policy code