Fixed a bug with getting appropriate value for msg variable