cleanup and error-fix