Updated code for issue #10.