Widget:refactor some part of code