make proper message serialization
add type for messages