refactored queue into tasks