cleaned up method to return values in JSON