added a me implementation and some math on the algo