fix bug and upgrade template