improve performance by optimizing per frame