Add cache function
Improve performance