using caching properly, only generate when needed