Error processing and bug fixed