Added in better error handling as well as more higher level function