implemented wait and exit