fixed the typo which from using the correct algorithm