add #1 algorithm