finish the basic function

and code refectory