Added connect feature and login refactoring