Adding basic algorithm