How facial recognition algorithm works