implemented direct run-length encoding (p13)