use update function to update ball positions