Break up the big function