refactor and bug fixed