added forward and backward substitution routines