Can we refactor this function to accept the object and id to make it more generic?