change implementation for getLatestId