modified slightly for protobuff