You’ve shown JS rather than Python code, but it looks like you’re experiencing a very common variable scope issue.
corr needs to be defined as well as msg