Simple implementation of basic algorithm.