My solution for ex 25