trivial refactoring
uses array size instead of a flag variable
be more structured
don't append newline in the end of output
move "ret +=" outside the cond
make message array first
simplifying them
cosmetic change
now no need for temporary val matched_xs