minor tidy up
fix print statement before assignment
tidy up logging
fix invalid log message