Not declared in scope, I have no idea why this isn't working

Simple check - count the opening braces { then count the closing braces }.

If the numbers are different then that's at least part of the problem. Each { must have a corresponding }. Same for ( and ).

Steve