chooseMasterWord function in place