Made template more robust