Move debug message to error check function.