test and optimize