 
   defp walk({:., _, [module, function]}, state) do
     if ElixirScript.Translate.Module.is_elixir_module(module) do
-      ModuleState.put_used_module(state.pid, state.module, module)
-
       if ModuleState.get_module(state.pid, module) == nil do
-        do_execute(module, state.pid)
+        case get_debug_info(module, state.pid) do
+          {:ok, _} = result ->
+            ModuleState.put_used_module(state.pid, state.module, module)
+            do_execute(module, result, state.pid)
+
+          result ->
+            do_execute(module, result, state.pid)
+        end
+      else
+        ModuleState.put_used_module(state.pid, state.module, module)
       end
     else
       walk(module, state)

  defp walk({:%, _, [module, params]}, state) do
    if ElixirScript.Translate.Module.is_elixir_module(module) and
         !ElixirScript.Translate.Module.is_js_module(module, state) do
      ModuleState.put_used_module(state.pid, state.module, module)

      if ModuleState.get_module(state.pid, module) == nil do
        do_execute(module, state.pid)
      end
    end


        raise ElixirScript.CompileError,
          message: "An error occurred while compiling #{inspect(module)}: #{error}",
          severity: :error
    end
  end

  defp do_execute(module, pid) do
    result = get_debug_info(module, pid)
    do_execute(module, result, pid)
  end

  defp get_debug_info(module, pid) do
    case ModuleState.get_in_memory_module(pid, module) do
      nil ->
        ElixirScript.Beam.debug_info(module)

      beam ->
        ElixirScript.Beam.debug_info(beam)
    end
  end

