work in progress. almost up to protocol