Thach dau logic