refactoring codes...