adding more logging and error catching