added updating funtion, but there are some bugs