algo seems working