finish the whole basic function