Work in progress: implement substitutions