breaking down big init function