reimplemented taskQueue to use a state machine