Added constructor and change curl call to use the caching function