now handles success and error messages