improved error handling, added payment handling