initial implementation and some tests