Optimization attempt with dictionary