diff --git a/search_replace_blocks_menus.admin.inc b/search_replace_blocks_menus.admin.inc
index f01a287..d839294 100644
--- a/search_replace_blocks_menus.admin.inc
+++ b/search_replace_blocks_menus.admin.inc
@@ -9,69 +9,53 @@
  * Form constructor for search_replace_blocks_menus_input_form form.
  */
 function search_replace_blocks_menus_input_form($form, &$form_state) {
-  if (isset($_SESSION['scanner_wholeword_checkbox'])) {
-    $whole_word = $_SESSION['scanner_wholeword_checkbox'];
-  }
-  else {
-    $whole_word = NULL;
-  }
-  // Set previous search string.
-  if (isset($_SESSION['scanner_search'])) {
-    $search = $_SESSION['scanner_search'];
-  }
-  else {
-    $search = NULL;
-  }
-  // Set previous replace string.
-  if (isset($_SESSION['scanner_replace'])) {
-    $replace = $_SESSION['scanner_replace'];
-  }
-  else {
-    $replace = NULL;
-  }
-  // Set previous selection of checkbox.
-  if (isset($_SESSION['scanner_block_checkbox'])) {
-    $scanner_block_checkbox = $_SESSION['scanner_block_checkbox'];
-  }
-  else {
-    $scanner_block_checkbox = 0;
-  }
-  // Set previous selection of checkbox.
-  if (isset($_SESSION['scanner_menu_checkbox'])) {
-    $scanner_menu_checkbox = $_SESSION['scanner_menu_checkbox'];
-  }
-  else {
-    $scanner_menu_checkbox = 0;
-  }
-  $form['checkbox'] = array(
-    '#type' => 'checkboxes',
-    '#options' => array(1 => t('Search Or Replace In Menus Title'), 2 => t('Search Or Replace In Blocks Body')),
-    '#title' => t('Search and replace in following locations'),
-    '#required' => TRUE,
-    '#default_value' => array($scanner_block_checkbox,$scanner_menu_checkbox),
+  if(!isset($form_state['values'])) {
+    $form_state['values'] = array();
+  }
+  $scanner = $form_state['values'] + array(
+    'wholeword_checkbox' => NULL,
+    'search' => NULL,
+    'replace' => NULL,
+    'block_checkbox' => NULL,
+    'menu_checkbox' => 0,
   );
-  $form['optional-checkbox'] = array(
-    '#type' => 'checkboxes',
-    '#options' => array(1 => t('Match whole word')),
-    '#required' => FALSE,
-    '#default_value' => array($whole_word),
+  
+  $form['locations'] = array(
+    '#type' => 'container',
+    '#prefix' => '<strong>' . t('Search and replace in following locations:') . '</strong>',
+    '#suffix' => '<br/>'
+  );
+  $form['locations']['menu_checkbox'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Search Or Replace In Menus Title'),
+    '#default_value' => $scanner['menu_checkbox'],
+  );  
+  $form['locations']['block_checkbox'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Search Or Replace In Blocks Body'),
+    '#default_value' => $scanner['block_checkbox'],
+  );
+  $form['wholeword_checkbox'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Match whole word'),
+    '#default_value' => $scanner['wholeword_checkbox'],
   );
-  $form['search_string'] = array(
+  $form['search'] = array(
     '#type' => 'textfield',
     '#title' => t('Search'),
     '#required' => TRUE,
-    '#default_value' => $search,
+    '#default_value' => $scanner['search'],
   );
   $form['search_submit'] = array(
     '#type' => 'submit',
     '#value' => t('Search'),
     '#submit' => array('search_replace_blocks_menus_form_submit_one'),
   );
-  $form['replace_string'] = array(
+  $form['replace'] = array(
     '#type' => 'textfield',
     '#title' => t('Replace'),
     '#required' => FALSE,
-    '#default_value' => $replace,
+    '#default_value' => $scanner['replace'],
   );
   $form['replace_submit'] = array(
     '#type' => 'submit',
@@ -86,39 +70,19 @@ function search_replace_blocks_menus_input_form($form, &$form_state) {
  */
 function search_replace_blocks_menus_form_submit_one($form, &$form_state) {
   // Set search and replace string in session.
-  $_SESSION['scanner_search']    = $form_state['values']['search_string'];
-  $_SESSION['scanner_replace']   = $form_state['values']['replace_string'];
-  if ($form['optional-checkbox'][1]['#checked'] == 1) {
-    $_SESSION['scanner_wholeword_checkbox'] = 1;
-  }
-  else {
-    $_SESSION['scanner_wholeword_checkbox'] = 0;
-  }
-  // Set checkbox selection in session.
-  if ($form['checkbox'][2]['#checked'] == 1) {
-    $_SESSION['scanner_block_checkbox'] = 2;
-  }
-  else {
-    $_SESSION['scanner_block_checkbox'] = 0;
-  }
-  if ($form['checkbox'][1]['#checked'] == 1) {
-    $_SESSION['scanner_menu_checkbox'] = 1;
-  }
-  else {
-    $_SESSION['scanner_menu_checkbox'] = 0;
-  }
+  $scanner = $form_state['values'];
   $oprator = 'LIKE';
-  if ($form['optional-checkbox'][1]['#checked'] == 1) {
-    $tmp = '[[:<:]]' . $form_state['values']['search_string'] . '[[:>:]]';
+  if ($scanner['wholeword_checkbox']) {
+    $tmp = '[[:<:]]' . $scanner['search'] . '[[:>:]]';
     $oprator = 'REGEXP';
   }
   else {
-    $tmp = '%' . db_like($form_state['values']['search_string']) . '%';
+    $tmp = '%' . db_like($scanner['search']) . '%';
   }
   $output = '';
   $options = array();
-  // Check search in block checkbox is checked or not.
-  if ($form['checkbox'][2]['#checked'] == 1) {
+  // Check search in block checkbox is checked or not. 
+  if ($scanner['block_checkbox']) {
     $result = db_select('block_custom', 'bc')
               ->fields('bc', array('info', 'bid'))
               ->condition('body', $tmp, $oprator)
@@ -135,7 +99,7 @@ function search_replace_blocks_menus_form_submit_one($form, &$form_state) {
     }
   }
   // Check search in menu checkbox is checked or not.
-  if ($form['checkbox'][1]['#checked'] == 1) {
+  if ($scanner['menu_checkbox']) {
     $query = db_select('menu_links', 'ml')->fields('ml', array('menu_name', 'mlid'));
     $db_or = db_or();
     $db_or->condition('link_title', $tmp, $oprator);
@@ -152,43 +116,25 @@ function search_replace_blocks_menus_form_submit_one($form, &$form_state) {
     }
   }
   drupal_set_message($output, 'status');
+  $form_state['rebuild'] = 1;
 }
 
 /**
  * Submission handler on Replace button.
  */
 function search_replace_blocks_menus_form_submit_two($form, &$form_state) {
-  $_SESSION['scanner_search']    = $form_state['values']['search_string'];
-  $_SESSION['scanner_replace']   = $form_state['values']['replace_string'];
-  if ($form['optional-checkbox'][1]['#checked'] == 1) {
-    $_SESSION['scanner_wholeword_checkbox'] = 1;
-  }
-  else {
-    $_SESSION['scanner_wholeword_checkbox'] = 0;
-  }
-  if ($form['checkbox'][2]['#checked'] == 1) {
-    $_SESSION['scanner_block_checkbox'] = 2;
-  }
-  else {
-    $_SESSION['scanner_block_checkbox'] = 0;
-  }
-  if ($form['checkbox'][1]['#checked'] == 1) {
-    $_SESSION['scanner_menu_checkbox'] = 1;
-  }
-  else {
-    $_SESSION['scanner_menu_checkbox'] = 0;
-  }
+  $scanner = $form_state['values'];
   $oprator = 'LIKE';
-  if ($form['optional-checkbox'][1]['#checked'] == 1) {
-    $tmp = '[[:<:]]' . $form_state['values']['search_string'] . '[[:>:]]';
+  if ($scanner['wholeword_checkbox']) {
+    $tmp = '[[:<:]]' . $scanner['search'] . '[[:>:]]';
     $oprator = 'REGEXP';
   }
   else {
-    $tmp = '%' . db_like($form_state['values']['search_string']) . '%';
+    $tmp = '%' . db_like($scanner['search']) . '%';
   }
   $output = '';
   // Check replace in block checkbox is checked or not.
-  if ($form['checkbox'][2]['#checked'] == 1) {
+  if ($scanner['block_checkbox']) {
     $result = db_select('block_custom', 'bc')
               ->fields('bc', array('bid', 'body', 'info'))
               ->condition('body', $tmp, $oprator)
@@ -196,17 +142,17 @@ function search_replace_blocks_menus_form_submit_two($form, &$form_state) {
               ->fetchAll();
     if (!empty($result)) {
       foreach ($result as $value) {
-        if ($form['optional-checkbox'][1]['#checked'] == 1) {
-          $body = preg_replace('/\b' . $form_state['values']['search_string'] . '\b/', check_plain($form_state['values']['replace_string']), $value->body);
+        if ($scanner['wholeword_checkbox']) {
+          $body = preg_replace('/\b' . $scanner['search'] . '\b/', check_plain($scanner['search']), $value->body);
         }
         else {
-          $body = str_replace($form_state['values']['search_string'], check_plain($form_state['values']['replace_string']), $value->body);
+          $body = str_replace($scanner['search'], check_plain($scanner['replace']), $value->body);
         }
         db_update('block_custom')
         ->fields(array('body' => $body))
         ->condition('bid', $value->bid, '=')
         ->execute();
-        $output .= t("Entered String Replaced by @string in block @block.<br />", array('@string' => $form_state['values']['replace_string'], '@block' => $value->info));
+        $output .= t("Entered String Replaced by @string in block @block.<br />", array('@string' => $scanner['replace'], '@block' => $value->info));
       }
     }
     else {
@@ -214,7 +160,7 @@ function search_replace_blocks_menus_form_submit_two($form, &$form_state) {
     }
   }
   // Check replace in menu checkbox is checked or not.
-  if ($form['checkbox'][1]['#checked'] == 1) {
+  if ($scanner['menu_checkbox']) {
     $query = db_select('menu_links', 'ml')
              ->fields('ml', array(
                  'mlid',
@@ -229,12 +175,12 @@ function search_replace_blocks_menus_form_submit_two($form, &$form_state) {
     $result = $query->execute()->fetchAll();
     if (!empty($result)) {
       foreach ($result as $value) {
-        $replacement = strip_tags($form_state['values']['replace_string']);
-        if ($form['optional-checkbox'][1]['#checked'] == 1) {
-          $title = preg_replace('/\b' . $form_state['values']['search_string'] . '\b/', check_plain($replacement), $value->link_title);
+        $replacement = strip_tags($scanner['replace']);
+        if ($scanner['wholeword_checkbox']) {
+          $title = preg_replace('/\b' . $scanner['search'] . '\b/', check_plain($replacement), $value->link_title);
         }
         else {
-          $title = str_replace($form_state['values']['search_string'], check_plain($replacement), $value->link_title);
+          $title = str_replace($scanner['search'], check_plain($replacement), $value->link_title);
         }
         db_update('menu_links')
         ->fields(array('link_title' => $title))
@@ -248,6 +194,7 @@ function search_replace_blocks_menus_form_submit_two($form, &$form_state) {
     }
   }
   drupal_set_message($output, 'status');
+  $form_state['rebuild'] = 1;
 }
 
 
@@ -255,7 +202,8 @@ function search_replace_blocks_menus_form_submit_two($form, &$form_state) {
  * Validate form.
  */
 function search_replace_blocks_menus_input_form_validate($form, &$form_state) {
-  if ($form_state['values']['replace_string'] == '' && $form_state['submit_handlers'][0] == 'search_replace_blocks_menus_form_submit_two') {
+  $scanner = $form_state['values'];
+  if ($scanner['replace'] == '' && $form_state['submit_handlers'][0] == 'search_replace_blocks_menus_form_submit_two') {
     form_set_error('replace_string', t('Please enter some keywords In Replace field.'));
     return;
   }
