Actually use the calculated solution. Fix unprotected for/in loop.