fixed bug with replacements
lots of progress made and first draft of code is 99% complete