a little logging, a litttle error checking