Modified the original code to include timestamp of messages