closed #16 and refactor.