Solution for the first exercise