Marlins beat D-Backs to snap 8-game losing streak