made functions more generic