add cache function, refactor method structure.