refactored add to queue