Refactored way to get msg_size