retrieving and updating instances logic