message formatting function and library