Added wait functionality