getting this error (pending kill or garbage)

Hey, appreciate the answer that actually makes a lot of sense, I just have to find a way to update the battery after the isValid. Thanks