Working substitute.

Now need to work on error messaging