returns json instead of writing to file unless testing