use api instead of looping through