Using substitution method to solve systems of equations