fix #8 and refactoring...