fixed issue #111
fixed issue #112 and a part of #106