refactored startup prep code