Add function and edit template lib