add end flag to final callback