Refactored connect with dropbox logic