new function for scriptManager, and some improve