Solution to second challenge