Re-factoring main