optimization and testing