modified some comments; adds callback function for producing error message;