change everything to use single function