improved code readability for rle encoding