refact main