bug fixes when receiving messages