diff --git a/configure.ac b/configure.ac
index 4bb549314ae1f16796f671c89fc06be6007280a7..35ad7c851589e5d3ad8fbd15e7a0309f6a1d5a40 100755
--- a/configure.ac
+++ b/configure.ac
@@ -18,7 +18,11 @@ CXXFLAGS+=" --std=c++11 -march=native -mtune=native -Wno-unused-local-typedefs -
 NVCCFLAGS=" "
 INCLUDES_PATH=" -Iconfig "
 
-# Add openfpm_pdata to prefix forlder
+# Add openfpm_io to prefix forlder (if prefix end if openfpm_pdata remove that path)
+if [ echo "$prefix" | grep -qE "/openfpm_pdata$" ]; then
+  prefix=$(echo "$prefix" | sed 's/\(.*\)\/openfpm_pdata$/\1/g')
+fi
+
 prefix="$prefix/openfpm_devices"
 echo "Installation dir is: $prefix"