added some error checking and updated README to contain examples