fix issues by refactor