Better symbol recognition algorithm