Implementation of some common algorithm