var should start the function block. 
Move the `if` block down and don't create variables there, just set values.
The item sett can be moved to a separate line outside the variable declaration since `data` may be reparsed in the `if