added some code for error handling, but not used