add cache code, and comment out some debug codes