fixed algo issues