Convert getValue and setValue to template functions