break down big functions. Closes #12