Unify main and extra files codes for simplifying