Improving an API callback and the declaration of map object