improved error handling, removed console loggings