added generic method to receive messages