Fixed bug when connecting for first time.