re-order handle custom msg and handle recieve state