refactor run length encoding example