fixed bug caused by 'msg = self.unpack(msg)' being in a loop