added arrays support to optimize{}