change api to return struct pointer