add condition for endData