HW3, optimization