better error handling in getLatest