optimized setup script