some cleanups on error funct