added if statements to stages to handle bubbles and stalls