refactor

code refactor with oo.