added karatsupa algorithm