add getting messages from server and some bug fixing