Template codes and some updated handle code