add a test for optimizing