fix algorithm

2