adding basic error checking and ability to pass in and api key