fixed operation purchase
added html escape function
added println of errors
improved error handling