move message parsing to a separate class