add optimization

Credits houstonn