Broke up tasks into several functions