Put script into functions