Troubleshooting "Optional attribute error"