added double array memory freeing function