added more abstraction for templating