Fix null pointer exception on updating