some refactoring & improvement
Merge pull request #1 from llicour/master

refactoring/improvement