Optimized variable event code