added backward substitution, probably doesn't work