Added finding optimal solution for all types