reactoring main