Refactored Q.Pipe to make it more robust