partially fixed refactored generator worker