A new approach to optimal embedding of time series