added two way computations
more error tolerant