function complete

but still have some bugs