Code refactoring process done.

Fixed bug related to the issue #139

Fixed bug related to the issue #138