Solution to the second challenge