issue-155: Removed unnecessary connection checking.

also formated code