fixed typo, but still didn't fix algorithm