fix receiving bugs and add error messages