Corrects bug and saves output as RData