message building function