Consolidated and made more DRY