Switch var to val (JavaScript has ruined me)