My attempt on solving the course exercises