better error handling.
fix 400 issue
fix 400 issue