completed ondig function