add a simple cache and fix a bug on render