slow algorithm