error checking and output