implement optimize option