updated calling function to clear before appending data