implementation for getFirst and getLatest