fixing error codes and data sending