Implementation of misc algorithms