Refactoring worklist directive to be more reusable