add flush cache method
fix if statement blocking