completed adding received message to buffer (need some refactoring)