made it handle different directories for saving JSON files