To gain a better understanding of why this was the correct decision, just think about the following.
Murray standing behind the opposition defenders in an offside position, Ryan kicks the ball forward, Murray runs from his offside position in the opposition half, and heads the ball just inside...