add text detecting function