added error checking for protocol
merge fix