Bug Fix - Master connection

Fixed the while loop for the master connection