added the ended flag
added ping()