diff --git a/tinybrowser.module b/tinybrowser.module
index 9849765..0d69a88 100644
--- a/tinybrowser.module
+++ b/tinybrowser.module
@@ -30,16 +30,15 @@ function tb_debug_log($str)
 function tinybrowser_get_tinymce_root() {
   if (module_exists("tinytinymce")) {
     $install_dir = drupal_get_path('module', 'tinytinymce');
-    if (file_exists($install_dir . '/tinymce/jscripts/tiny_mce/tiny_mce.js')) {
-      return '../../tinytinymce/tinymce/jscripts/tiny_mce';
-    }
   }
   else if (module_exists("wysiwyg")) {
     $install_dir = wysiwyg_get_path('');
-    if (file_exists($install_dir . '/tinymce/jscripts/tiny_mce/tiny_mce.js')) {
-      return '../../../libraries/tinymce/jscripts/tiny_mce';
-    }
   }
+
+  if (file_exists($install_dir . 'tinymce/jscripts/tiny_mce/tiny_mce.js')) {
+    return '/' . $install_dir . 'tinymce/jscripts/tiny_mce';
+  }
+
   return '';
 }
 
diff --git a/tinybrowser/config_tinybrowser.php b/tinybrowser/config_tinybrowser.php
index ae5f21a..105cb23 100644
--- a/tinybrowser/config_tinybrowser.php
+++ b/tinybrowser/config_tinybrowser.php
@@ -1,23 +1,15 @@
 <?php
 //-------- Start: original code for Drupal TinyBrowser module ----------
 $current_dir = getcwd();
-if (file_exists("../../../../../includes/bootstrap.inc")) {
-  // If this script is in the 
-  //    (drupal-root)/sites/(site)/modules/tinybrowser/tinybrowser/
-  chdir('../../../../../');
-}
-else if (file_exists("../../../../../../includes/bootstrap.inc")) {
-  // If this script is in the 
-  //    (drupal-root)/sites/(site)/modules/tinybrowser/tinybrowser/js/
-  chdir('../../../../../../');
-}
-else if (file_exists("../../../includes/bootstrap.inc")) {
-  // If this script is in the (drupal-root)/modules/tinybrowser/tinybrowser/
-  // ---NOTE--- It is not recommended to install contributed modules there!
-  chdir('../../../');
+$found_directory = FALSE;
+for ($i = 0; $i <= 10; $i++) {
+  if (file_exists(str_repeat('../', $i) . 'includes/bootstrap.inc')) {
+    chdir(str_repeat('../', $i));
+    $found_directory = TRUE;
+    break;
+  }
 }
-else {
-  // other odd directories - not supported
+if (!$found_directory) {
   print "Error: TinyBrowser module failed. Please refer to the README.txt.\n";
   exit;
 }
