Closes #3 / Split substituting function