edited optimizatino