added cache function for stan outside stantrainer class