resolve #10 and refactoring