added run length encoding