Enumerate method to find optimum