added  as a stand alone function, and a small cache thing