Added case switch for message sorting