Implemeted th waitfg method