add test code for optimization