added debug handler for output to stderr