Put script in function