#219 Fix bugs, add implementation for update