abstract out one func