diff --git a/webform_conditional.js b/webform_conditional.js
index c7ffa2f..e43e71c 100755
--- a/webform_conditional.js
+++ b/webform_conditional.js
@@ -7,19 +7,19 @@ Drupal.behaviors.webform_conditional = {
 	attach: function() {
       $.each(Drupal.settings.webform_conditional.fields, function(dependentField, dependentInfo) {
 		
-		var formItemWrapper = Drupal.behaviors.webform_conditional.getWrapper(dependentInfo);
+		var formItemWrapper = Drupal.webform_conditional.getWrapper(dependentInfo);
 		if(formItemWrapper.length > 0){
 			formItemWrapper.css("display", "none");
 			// Add onclick handler to Parent field
-			Drupal.behaviors.webform_conditional.addOnChange (dependentField, dependentInfo);
+			Drupal.webform_conditional.addOnChange (dependentField, dependentInfo);
 		}
 		});
 	  //after all added - trigger initial 
 	  $.each(Drupal.settings.webform_conditional.fields, function(dependentField, dependentInfo) {
-		var formItemWrapper = Drupal.behaviors.webform_conditional.getWrapper(dependentInfo);
+		var formItemWrapper = Drupal.webform_conditional.getWrapper(dependentInfo);
 			if(formItemWrapper.length > 0){
-				var field_name = Drupal.behaviors.webform_conditional.escapeId(dependentInfo['monitor_field_key']);
-				var components = Drupal.behaviors.webform_conditional.getComponentsByName(field_name);
+				var field_name = Drupal.webform_conditional.escapeId(dependentInfo['monitor_field_key']);
+				var components = Drupal.webform_conditional.getComponentsByName(field_name);
 				if(components.attr('type')=='radio' || components.attr('type')=='checkbox'){
 					$(components[0]).triggerHandler('click');
 				}else{
@@ -31,78 +31,68 @@ Drupal.behaviors.webform_conditional = {
 	}
 };
 //create quasi static var to save perfomance
-Drupal.behaviors.webform_conditional.wrappers = new Object();
-Drupal.behaviors.webform_conditional.getWrapper = {
-	attach: function(dependentInfo){
-	  if(Drupal.behaviors.webform_conditional.wrappers[dependentInfo['css_id']]){
-		  return Drupal.behaviors.webform_conditional.wrappers[dependentInfo['css_id']];
+Drupal.webform_conditional = new Object();
+Drupal.webform_conditional.wrappers = new Object();
+Drupal.webform_conditional.getWrapper = function(dependentInfo){
+	  if(Drupal.webform_conditional.wrappers[dependentInfo['css_id']]){
+		  return Drupal.webform_conditional.wrappers[dependentInfo['css_id']];
 	  }
-	  return Drupal.behaviors.webform_conditional.wrappers[dependentInfo['css_id']] = $("#" + dependentInfo['css_id']);
-	}
+	  return Drupal.webform_conditional.wrappers[dependentInfo['css_id']] = $("#" + dependentInfo['css_id']);
 };
-Drupal.behaviors.webform_conditional.addOnChange = {
-	attach: function(dependentField, dependentInfo) {
-	  var monitor_field_name = Drupal.behaviors.webform_conditional.escapeId(dependentInfo['monitor_field_key']);
+Drupal.webform_conditional.addOnChange = function(dependentField, dependentInfo) {
+	  var monitor_field_name = Drupal.webform_conditional.escapeId(dependentInfo['monitor_field_key']);
 	  var changeFunction = function() {
-		Drupal.behaviors.webform_conditional.setVisibility(dependentField,dependentInfo);
+		Drupal.webform_conditional.setVisibility(dependentField,dependentInfo);
 	  };
-	  var components = Drupal.behaviors.webform_conditional.getComponentsByName(monitor_field_name);
+	  var components = Drupal.webform_conditional.getComponentsByName(monitor_field_name);
 	  if(components.attr('type')=='radio' || components.attr('type')=='checkbox'){
 		components.click(changeFunction);
 	  }else{
 		components.change(changeFunction);
 	  }
-	}
 };
-Drupal.behaviors.webform_conditional.setVisibility = {
-	attach: function(dependentField,dependentInfo,monitorField,monitorInfo){
-	  monitor_field_name = Drupal.behaviors.webform_conditional.escapeId(dependentInfo['monitor_field_key']);
-	  var currentValues = Drupal.behaviors.webform_conditional.getFieldValue(monitor_field_name); 
+Drupal.webform_conditional.setVisibility = function(dependentField,dependentInfo,monitorField,monitorInfo){
+	  monitor_field_name = Drupal.webform_conditional.escapeId(dependentInfo['monitor_field_key']);
+	  var currentValues = Drupal.webform_conditional.getFieldValue(monitor_field_name); 
 	  var monitor_visible = true;
 	  if(monitorField !== undefined){
-		monitor_visible = Drupal.behaviors.webform_conditional.getWrapper(monitorInfo).data('wfc_visible');
+		monitor_visible = Drupal.webform_conditional.getWrapper(monitorInfo).data('wfc_visible');
 	  }
-	  if(((dependentInfo['operator'] == "=" && !Drupal.behaviors.webform_conditional.Matches(currentValues,dependentInfo['monitor_field_value']))
-		|| (dependentInfo['operator'] == "!=" && Drupal.behaviors.webform_conditional.Matches(currentValues,dependentInfo['monitor_field_value']))) 
+	  if(((dependentInfo['operator'] == "=" && !Drupal.webform_conditional.Matches(currentValues,dependentInfo['monitor_field_value']))
+		|| (dependentInfo['operator'] == "!=" && Drupal.webform_conditional.Matches(currentValues,dependentInfo['monitor_field_value']))) 
 		|| !monitor_visible){
 			// show the hidden div
 			// have to set wfc_visible so that you check the visibility of this immediately  
-		   Drupal.behaviors.webform_conditional.getWrapper(dependentInfo).hide().data('wfc_visible',false);
+		   Drupal.webform_conditional.getWrapper(dependentInfo).hide().data('wfc_visible',false);
 	  }else {
 			// otherwise, hide it
-		Drupal.behaviors.webform_conditional.getWrapper(dependentInfo).show().data('wfc_visible',true);
+		Drupal.webform_conditional.getWrapper(dependentInfo).show().data('wfc_visible',true);
 			// and clear data (using different selector: want the
 			// textarea to be selected, not the parent div)
 	  }
-	  Drupal.behaviors.webform_conditional.TriggerDependents(dependentField,dependentInfo);
-	}
+	  Drupal.webform_conditional.TriggerDependents(dependentField,dependentInfo);
 };
-Drupal.behaviors.webform_conditional.components = new Object();
-Drupal.behaviors.webform_conditional.getComponentsByName = {
-	attach: function (field_name){
+Drupal.webform_conditional.components = new Object();
+Drupal.webform_conditional.getComponentsByName = function (field_name){
 	  //check to save jquery calls
-	  if(Drupal.behaviors.webform_conditional.components[field_name]){
-		return Drupal.behaviors.webform_conditional.components[field_name];
+	  if(Drupal.webform_conditional.components[field_name]){
+		return Drupal.webform_conditional.components[field_name];
 	  }
 	  field_name = "[" + field_name + "]";
 	  var nid = Drupal.settings.webform_conditional.nid;
 	  if(nid instanceof Array){
 		nid = Drupal.settings.webform_conditional.nid[0];
 	  }
-	  return Drupal.behaviors.webform_conditional.components[field_name] = $("#webform-client-form-" + nid + " *[name*='"+field_name+"']");
-	}
+	  return Drupal.webform_conditional.components[field_name] = $("#webform-client-form-" + nid + " *[name*='"+field_name+"']");
 };
-Drupal.behaviors.webform_conditional.TriggerDependents = {
-	attach: function(monitorField,monitorInfo){
+Drupal.webform_conditional.TriggerDependents = function(monitorField,monitorInfo){
 	  $.each(Drupal.settings.webform_conditional.fields, function(dependentField, dependentInfo) {
 		if(dependentInfo['monitor_field_key'] == monitorField){
-		  Drupal.behaviors.webform_conditional.setVisibility(dependentField, dependentInfo,monitorField,monitorInfo);
+		  Drupal.webform_conditional.setVisibility(dependentField, dependentInfo,monitorField,monitorInfo);
 		};
 	  });
-	}
 };
-Drupal.behaviors.webform_conditional.getFieldValue = {
-	attach: function(field_name){
+Drupal.webform_conditional.getFieldValue = function(field_name){
 	  field_name = "[" + field_name + "]";
 	  var selected = [];
 	  var vals = [];
@@ -118,10 +108,8 @@ Drupal.behaviors.webform_conditional.getFieldValue = {
 	     vals[i] = $(this).val();
 	    });
 	  return vals;
-	}
 };
-Drupal.behaviors.webform_conditional.Matches = {
-	attach: function(currentValues,triggerValues){
+Drupal.webform_conditional.Matches = function(currentValues,triggerValues){
 	  var found = false;
 	  $.each(triggerValues, function(index, value) { 
 		  if(jQuery.inArray(value,currentValues)> -1){
@@ -130,13 +118,10 @@ Drupal.behaviors.webform_conditional.Matches = {
 		  }
 		});
 	  return found;
-	}
 };
-//Drupal.behaviors.webform_conditional.escapeId
-Drupal.behaviors.webform_conditional.escapeId = {
-	attach: function(myid) { 
+//Drupal.webform_conditional.escapeId
+Drupal.webform_conditional.escapeId = function(myid) { 
 	   return  myid.replace(/(:|\.)/g,'\\$1');
-	}
 };
 
 })(jQuery);
\ No newline at end of file
diff --git a/webform_conditional.module b/webform_conditional.module
index 4ae8940..1892691 100755
--- a/webform_conditional.module
+++ b/webform_conditional.module
@@ -15,18 +15,18 @@
 function webform_conditional_form_webform_component_edit_form_alter(&$form, &$form_state) {
 	//not all types are hideable by this module
 	if (_webform_conditional_type_is_hideable($form['type']['#value'])) {
-		$triggerComponents = _webform_conditional_possible_trigger_components($form['nid']['#value'], $form['cid']['#value']);
+	  $triggerComponents = _webform_conditional_possible_trigger_components($form['nid']['#value'], $form['cid']['#value']);
 		if (!empty($triggerComponents)) {
-			//if there are any same page component add function to handle values
+		  //if there are any same page component add function to handle values
 			array_unshift($form['#submit'], 'webform_condtional_component_edit_submit');
 			$form['conditional']['#access'] = TRUE;
 			$form['conditional']['extra']['conditional_component']['#options'] =  $form['conditional']['extra']['conditional_component']['#options'] + $triggerComponents;
 			$default_value = trim($form['conditional']['extra']['conditional_values']['#default_value']);
 			if (empty($default_value)) {
-				//no regular conditional values
+			  //no regular conditional values
 				if(!empty($form['cid']['#value'])){
 					$sql = "SELECT extra FROM {webform_component} where nid = :nid and cid = :cid";
-					$result = db_query($sql, array($form['nid']['#value'], $form['cid']['#value']));
+					$result = db_query($sql, array(':nid'=>$form['nid']['#value'], ':cid'=>$form['cid']['#value']));
 					if ($row = $result->fetchAssoc()) {
 						//not dealing with a new component
 						$extra = unserialize($row['extra']);
@@ -197,8 +197,8 @@ function _webform_conditional_convert_textarea_lines_to_array($textarea_value) {
  */
 function webform_conditional_element_after_build($form_element, &$form_state) {
 	//only do this when the form is being submitted NOT displayed
-	if (!empty($form_element['#post'])) {
-		$submitted_values = _webform_conditional_get_submitted_values($form_state);
+	if (!empty($form_state['input'])) {
+	  $submitted_values = _webform_conditional_get_submitted_values($form_state);
 		//load the components into a flattened array
 		$components = _webform_conditional_get_all_components($form_element['#webform_component']['nid'], $submitted_values);
 		$was_hidden = _webform_conditional_was_hidden($form_element['#webform_component']['cid'], $components);
@@ -547,8 +547,8 @@ function _webform_conditional_get_base_component($nid, $cid) {
  * If submitted_data given add to each component
  */
 function _webform_conditional_get_all_components($nid, $submitted_data = array()) {
-	$sql = "SELECT * FROM {webform_component} where nid = ?";
-	$result = db_query($sql, array($nid));
+	$sql = "SELECT * FROM {webform_component} where nid = :nid";
+	$result = db_query($sql, array(':nid' => $nid));
 	$components = array();
 	while ($component = $result->fetchAssoc()) {
 		$component['extra'] = unserialize($component['extra']);
