fixing some bugs with updating table