Refactored JSON functions out of main form