fixed bug that would not connect automatically in some occasions