Fix loop problems. TODO : Fix connection