some added error checking and returning error results from server in some cases