refactoring. should not throw error if invalid json string