optimize obb algorithm