Adding var declarations to prevent memory leaks (minor)