Fixed getMsg function, thanks to shifu.