adds logging for better error reporting