looks good. So everything before here in this function I should probably split out to avoid copy/past code right?