Added JSON parser and handle errors better