working more flexible template with example using r data