Adding encoding to both functions