performance improvement by rendering only when needed.