Modified to be a generic base for creation of functions