Refactor creatnet()