Some naive code when I was exercise the algorithm