adding some basic error checking for protocol