More work on my first algorithm