closed #5005, refactor