added comments.
added a system to run a query in case of errors