refactored creating queue