Make functions more generic