added template retrieval
merged changes