made string encoder class method so it can be used everywhere