factor init method into smaller pieces for clarity and modularity