Introduce message class to simplify code