diff --git a/route_planner.js b/route_planner.js
index 05e45cd..1befc18 100644
--- a/route_planner.js
+++ b/route_planner.js
@@ -10,9 +10,8 @@ Drupal.behaviors.routeplanner = {
 };
 
 Drupal.RoutePlanner = function() {
-  var directionDisplay;
-  var directionsService = new google.maps.DirectionsService();
-  var map;
+  this.directionsService = new google.maps.DirectionsService();
+  this.map = null;
 
   // initialize the map
   this.route();
@@ -23,7 +22,7 @@ Drupal.RoutePlanner.prototype.route = function(){
   geocoder = new google.maps.Geocoder();
   var latLng;
   if (geocoder) {
-    geocoder.geocode( { "address": address}, function(results, status) {
+    geocoder.geocode( { "address": Drupal.settings.routePlanner['address']}, function(results, status) {
       if (status == google.maps.GeocoderStatus.OK) {
          latLng = new String(results[0].geometry.location);
          latLng = latLng.substr(1, (latLng.length-2) );
@@ -31,39 +30,41 @@ Drupal.RoutePlanner.prototype.route = function(){
          var location = new google.maps.LatLng(latLng[0], latLng[1]);
 
   	   var myOptions = {
-  	     zoom: zoomlevel,
+  	     zoom: Drupal.settings.routePlanner['zoomlevel'],
   	     mapTypeId: google.maps.MapTypeId.ROADMAP,
   	     center: location
   	   }
-         map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
+         this.map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
          var marker = new google.maps.Marker({
-           map: map,
+           map: this.map,
            position: results[0].geometry.location
          });
-         directionsDisplay.setMap(map);
+         directionsDisplay.setMap(this.map);
       } else {
         alert(Drupal.t("Geocode was not successful for the following reason: ") + status);
       }
     });
   }
+  return false;
 }
 
 Drupal.RoutePlanner.prototype.calcRoute = function(){
   var start = document.getElementById("edit-start").value;
   var request = {
       origin:start,
-      destination:end,
+      destination: Drupal.settings.routePlanner['end'],
       travelMode: google.maps.DirectionsTravelMode.DRIVING
   };
-  directionsService.route(request, function(response, status) {
+  this.directionsService.route(request, function(response, status) {
     if (status == google.maps.DirectionsStatus.OK) {
-      directionsDisplay.setDirections(response);
+      this.directionsDisplay.setDirections(response);
       distance = response.routes[0].legs[0].distance.text;
       time = response.routes[0].legs[0].duration.text;
       document.getElementById("edit-time").value = time;
       document.getElementById("edit-distance").value = distance;
     }
   });
+  return false;
 }
 
 })(jQuery);
\ No newline at end of file
diff --git a/route_planner.module b/route_planner.module
index 62105e9..9e1c444 100644
--- a/route_planner.module
+++ b/route_planner.module
@@ -79,7 +79,7 @@ function route_planner_address_form($form, &$form_state) {
     '#type' => 'button',
     '#value' => t('Calculate Route'),
   );
-  $form['button']['#attributes'] = array('onClick' => 'Drupal.myRoutePlanner.calcRoute();return (false);');
+  $form['button']['#attributes'] = array('onClick' => 'return Drupal.myRoutePlanner.calcRoute()');
 
   return $form;
 }
@@ -90,11 +90,13 @@ function route_planner_get_address_form() {
   // add some custom Java Script to display the map
   drupal_add_js(drupal_get_path('module', 'route_planner') . '/route_planner.js');
   // set variables from Route Planner settings page
-  drupal_add_js('
-    var address = "' . variable_get('rp_address', 'Hamburg, Germany') . '";
-    var zoomlevel = ' . variable_get('rp_map_zoom', '10') . ';
-	var end = "' . variable_get('rp_address', 'Hamburg, Germany') . '";
-  ', 'inline');
+  drupal_add_js(array(
+    'routePlanner' => array(
+      'address' => variable_get('rp_address', 'Hamburg, Germany'),
+      'zoomlevel' => variable_get('rp_map_zoom', 10),
+      'end' => variable_get('rp_address', 'Hamburg, Germany'),
+    ),
+  ), 'setting');
 
   // get the address form
   $output =  drupal_get_form('route_planner_address_form');
