redo resource fn and remove crusty code