def for optimize