Those additional "var"s are causing the creation of local variables named "locatie" which are getting set instead of the global variable with the same name. Remove those highlighted "var" declarations and your code should start working.