output correct, gets all messages right, but Code has to be better
structured