fix the bug when a self connection is created.
arrange the code. use jQuery and jQuery via CDN of Google API