Code cleanup

cleanup of code and refactor to use jsonFilename from global scope