PHOENIX – After a very difficult homestand in which they lost all five games they played, the Cubs managed to get some redemption away from Wrigley Field over the past week.

A lot of that had to do with their work in the final innings in a few of those victories.

Three times in their last six games, the Cubs took the lead in the eighth or ninth inning, doing so twice this weekend against the Diamondbacks to finish their six-game west swing with a 4-2 record. It improves their overall mark to 13-20 as they return to Chicago for a seven-game homestand starting Monday night against the Pirates.

On Sunday the team got the run they needed in the ninth as a Patrick Wisdom double and Frank Schwindel single put the Cubs up 3-2. Scott Effross and Rowan Wick would each allow hits in the ninth, but the latter would get a double play to finish off a series-clinching victory.

Saturday night had a similar scenario with the Cubs taking the lead over Arizona with three runs in the top of the ninth inning. They drew three walks and had two hits against Mark Melancon and J.B. Wendelken to get the job done in what would end up being a 4-2 victory.

Those wins came after a loss on Friday against the Diamondbacks in which an early 3-0 lead got away in a 4-3 defeat.

The Cubs also clinched a series win against San Diego on Thursday with a pair of late runs that broke the tied contest, with Alfonso Rivas’ two-RBI single in the eighth putting them ahead for good in a 7-5 victory. They nearly had another comeback on Wednesday when they entered the ninth down by two runs at Petco Park. Ian Happ’s single gave the Cubs the lead and Schwindel narrowly missed a go-ahead Grand Slam with two outs.

But the long drive was caught at the wall, giving the Padres a victory.

With the victories, the Cubs’ road record improved to 9-9 this season and they’ll hope to improve their 4-11 home mark with three games against the Pirates and four in the return match-up with Arizona this week at Wrigley Field.