formatting and a little extra logging for debugging purposes