adding some logging to satisfy curiosity
formatting
fixed missing variable
adding output variable