Refactoring for queue file logic