added verbose feature and improved error handling