fixing rescoping problem