recognition algorithm