Performance improvement by doing expensive tasks only once