I'm not sure what your code is supposed to do, as the logic seems pretty wonky.

But since your question was on syntax, I'll just answer that part:

Curly brackets denote a block of code, which...