Fix script function