Update sc.c for thread-safe error checking