complete implementation and test