Fixed to use newly allocated array to create next method.
Added missing export method.