implement script function