added cache function for stan