finished the basic function