Simplify code
Properly declare variables with 'var'