merged/refactored advanced tempaltes