fixed some little bugs,and added the mechanism of handling the errors
fix bugs