Solution of #40.