Fix DB updating code