fixed callback when error and minor bugs