require JSON and handle errors better