fix algorithm error