add waiting for end