finished impl and tests