added substitutions and row shifts