encode (don't make changes to this, i'm working on it)