Updated solution for PE#10